/**
 * 上传文件
 */
interface postAttachmentResponse extends BaseResponse {
    filePath: string
}
/**
 * 文件服务 
 */
interface IAttachmentService {
    /**
     * 上传文件
     * @param id 附件编号
     */
    postAttachment(): ng.IHttpPromise<postAttachmentResponse>;
    /**
     * 下载文件
     */
    getAttachment(id: string): ng.IHttpPromise<BaseResponse>;

    getAttachmentStr(id:string):ng.IHttpPromise<BaseResponse>;
}

class attachmentService implements IAttachmentService {
    constructor(private http: ng.IHttpService, private route: routeService) {
    }

    postAttachment(): ng.IHttpPromise<postAttachmentResponse> {
        return this.http<postAttachmentResponse>({
            method: "POST",
            url: this.route.getUrl("attachment", {
            })
        });
    }
    getAttachment(id: string): ng.IHttpPromise<BaseResponse> {
        return this.http<BaseResponse>({
            method: "GET",
            url: this.route.getUrl("attachment?id={{id}}", {
                id: encodeURIComponent(id)
            })
        });
    }

    getAttachmentStr(id: string): ng.IHttpPromise<BaseResponse> {
        return this.http<BaseResponse>({
            method: "GET",
            url: this.route.getUrl("attachment/GetStr?id={{id}}", {
                id: encodeURIComponent(id)
            })
        });
    }
}
angular.module("attachmentService",[]).service("attachmentService", ['$http', 'routeService', attachmentService]);


